<template>
    <div class="app-container">
        <div style="display: flex">
            <el-form :model="datess" ref="queryForm" size="small" :inline="true" v-show="showSearch">
              <el-form-item label="开始时间">
                <el-date-picker value-format="yyyy-MM-dd HH:mm:ss" v-model="datess.startTime" type="datetime"
                  placeholder="选择日期时间">
                </el-date-picker>
              </el-form-item>
              <el-form-item label="结束时间">
                <el-date-picker value-format="yyyy-MM-dd HH:mm:ss" v-model="datess.endTime" type="datetime"
                  placeholder="选择日期时间">
                </el-date-picker>
              </el-form-item>
              <el-form-item>
                <el-button type="primary" icon="el-icon-search" size="mini" @click="zhenghandleQuery">搜索</el-button>
                <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
              </el-form-item>
            </el-form>
          </div>
  
          <el-table v-loading="loading" :data="zhengroleList" >
            <!-- <el-table-column type="selection" width="55" align="center" /> -->
            <!-- <el-table-column fixed label="客服名称" prop="serviceName" /> -->
            <el-table-column label="系列" prop="attribute" 
            :show-overflow-tooltip="true" width="150" />
            <el-table-column label="应收" prop="totalBillReceivable"
             :show-overflow-tooltip="true" width="150" />
  
            <el-table-column label="客户数量" prop="customerCount" />
  
            <el-table-column label="新客户数量" prop="newCustomerCount" />
  
            <el-table-column label="应收占比" prop="receivableRatio" />
            <el-table-column label="客户数量占比" prop="customerRatio" />
  
            <el-table-column label="新客户数量占比" prop="newCustomerRatio" />
           
  
          </el-table>
    </div>
  </template>
  
  <script>
  import { getRole } from "@/api/system/role";
  import tab from './tab.vue'
  import { chulikesu, getjyue, getjyues, zhenggetjyues,xilie } from "@/api/new";
  import { treeselect as menuTreeselect } from "@/api/system/menu";
  
  export default {
    name: "Role",
    dicts: ["sys_normal_disable"],
  
    components: { tab },
    data() {
      return {
        // 遮罩层
        loading: true,
        activeName: "first",
        // 选中数组
        ids: [],
        // 非单个禁用
        single: true,
        // 非多个禁用
        multiple: true,
        // 显示搜索条件
        showSearch: true,
        // 总条数
        total: 0,
        // 角色表格数据
        roleList: [],
        zhengroleList: [],
        wanjiekopng: false,
        // 弹出层标题
        title: "",
        kesuwanfrom: {
          orderId: "",
          disposeResult: "",
        },
        kesuwanfromre: {
          disposeResult: [
            { required: true, message: "处理结果不能为空", trigger: "blur" },
          ],
        },
        datess: {
          startTime:'',endTime:''
        },
        // 是否显示弹出层
        open: false,
        // 是否显示弹出层（数据权限）
        openDataScope: false,
        menuExpand: false,
        menuNodeAll: false,
        deptExpand: true,
        deptNodeAll: false,
        // 日期范围
        dateRange: [],
        // 数据范围选项
        secvalue: "",
        // 菜单列表
        menuOptions: [],
        // 部门列表
        deptOptions: [],
        options: [
          {
            value: "按月查询",
            label: "按月查询",
          },
          {
            value: "按年查询",
            label: "按年查询",
          },
        ],
        // 查询参数
        queryParams: {
          startTime: '',
          endTime: '',
          pageNo: 1,
          pageSize: 10,
        },
        dates: {
          month: "",
          years: "",
        },
        // 表单参数
        form: {},
        defaultProps: {
          children: "children",
          label: "label",
        },
        // 表单校验
        rules: {
          roleName: [
            { required: true, message: "角色名称不能为空", trigger: "blur" },
          ],
          roleKey: [
            { required: true, message: "权限字符不能为空", trigger: "blur" },
          ],
          roleSort: [
            { required: true, message: "角色顺序不能为空", trigger: "blur" },
          ],
        },
      };
    },
    created() {
      this.zhenggetList();
    },
    methods: {
      dangyue() {
        // 获取当前日期
        const now = new Date();
  
        // 获取年份，getFullYear()方法会返回一个四位的年份
        const year = now.getFullYear();
  
        // 获取月份，getMonth()方法返回的月份是从0开始的，所以需要加1
        const month = (now.getMonth() + 1).toString().padStart(2, "0");
  
        // 使用模板字符串或者字符串连接来组合年份和月份
        // return `${year}-${month}`;
        this.dates.month = `${year}-${month}`;
        this.getList();
      },
      dangnian() {
        const now = new Date();
  
        // 获取年份，getFullYear()方法会返回一个四位的年份
        const year = now.getFullYear();
  
        console.log(year);
        this.dates.years = `${year}`;
        this.getLists();
      },
      guanbishoukan() {
        this.kesuwanfrom = {
          orderId: "",
          disposeResult: "",
        };
      },
 
  
      /** 查询角色列表 */
      getList() {
        this.loading = true;
        getjyue({ date: this.dates.month }).then((response) => {
          this.roleList = response.data;
          this.loading = false;
        });
      },
      getLists() {
        this.loading = true;
        getjyues({ date: this.dates.years }).then((response) => {
          this.roleList = response.data;
          this.loading = false;
        });
      },
  
      // 所有菜单节点数据
      getMenuAllCheckedKeys() {
        // 目前被选中的菜单节点
        let checkedKeys = this.$refs.menu.getCheckedKeys();
        // 半选中的菜单节点
        let halfCheckedKeys = this.$refs.menu.getHalfCheckedKeys();
        checkedKeys.unshift.apply(checkedKeys, halfCheckedKeys);
        return checkedKeys;
      },
      // 所有部门节点数据
      getDeptAllCheckedKeys() {
        // 目前被选中的部门节点
        let checkedKeys = this.$refs.dept.getCheckedKeys();
        // 半选中的部门节点
        let halfCheckedKeys = this.$refs.dept.getHalfCheckedKeys();
        checkedKeys.unshift.apply(checkedKeys, halfCheckedKeys);
        return checkedKeys;
      },
      zhenghandleQuery() {
        this.zhenggetList();
      },
      zhenggetList() {
        this.loading = true;
        xilie(this.datess).then((response) => {
          this.zhengroleList = response.rows;
          this.loading = false;
        });
      },
      /** 搜索按钮操作 */
      handleQuery() {
        this.queryParams.pageNo = 1;
        this.getList();
      },
      handleQuerys() {
        this.queryParams.pageNo = 1;
        this.getLists();
      },
      /** 重置按钮操作 */
      resetQuery() {
        this.datess = {
          month: "",
          years: "",
        };
      },
    
  
  
    },
  };
  </script>
  